console.log('one');
var data_zh = ['一','二','三','四','五','六'];
var data_en = ['one','two','three','four','five','six'];

var text_if = document.querySelector("#text_if");
var text_that = document.querySelector("#text_that");
var btn_if = document.querySelectorAll("#btn_if button");
var btn_that = document.querySelectorAll("#btn_that button");

var lang = 'zh';

function swap(){
	if (lang === 'zh') {
		lang = 'en';
	} else{
		lang = 'zh';
	}
	for (var i = 0;i < btn_if.length;i++) {
		btn_if[i].classList.remove("btn-primary");
		btn_if[i].classList.remove("btn-light");
		btn_that[i].classList.remove("btn-primary");
		btn_that[i].classList.remove("btn-light");
	}
	switch(lang){
		case'en':
		btn_if[0].classList.add("btn-light");
		btn_if[1].classList.add("btn-primary");
		btn_that[0].classList.add("btn-light");
		btn_that[1].classList.add("btn-primary");
		break;
		case'zh':
		btn_if[0].classList.add("btn-primary");
		btn_if[1].classList.add("btn-light");
		btn_that[0].classList.add("btn-primary");
		btn_that[1].classList.add("btn-light");
		break;
	}
}

function res(){
	for (var i in data_zh) {
		if(text_if.value === data_zh[i]){
			text_that.value = data_en[i];
			if(lang === 'en'){
				swap();
			}
		}
	}
	for (var i in data_en) {
		if (text_if.value === data_en[i]) {
			text_that.value = data_zh[i];
			if (lang === 'zh') {
				swap();
			}
		}
	}
}
